﻿<phone:PhoneApplicationPage 
    x:Class="Croxweb.Leuphana.Pages.LecturePage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:local="clr-namespace:Croxweb.Leuphana.Pages"
    xmlns:tilt="clr-namespace:ControlTiltEffect"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--Transitions-->
    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:SlideTransition Mode="SlideDownFadeIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:SlideTransition Mode="SlideUpFadeIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:SlideTransition Mode="SlideDownFadeOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:SlideTransition Mode="SlideUpFadeOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <!--LayoutRoot-->
    <Grid x:Name="LayoutRoot" Background="Transparent">

        <!--Pivot-->
        <controls:Pivot Title="{Binding Title, Converter={StaticResource UpperCaseConverter}}">

            <!--Details and persons-->
            <controls:PivotItem Header="Details">
                <ScrollViewer>
                    <StackPanel Margin="0,0,0,24">
                        <!--Persons-->
                        <ListBox ItemsSource="{Binding Persons}" SelectionChanged="Persons_SelectionChanged"
                                 ScrollViewer.VerticalScrollBarVisibility="Disabled" Margin="0,0,0,24">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal" Margin="16,6,0,0" tilt:TiltEffect.IsTiltEnabled="True">
                                        <Border Height="62" Width="62" Background="{StaticResource PhoneAccentBrush}" />
                                        <TextBlock Text="{Binding FullName}" TextWrapping="Wrap" Style="{StaticResource PhoneTextExtraLargeStyle}" />
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>

                        <!--Details-->
                        <StackPanel Height="{Binding DetailsExpanded}">
                            <TextBlock Text="{Binding Details}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"
                                       LineStackingStrategy="BlockLineHeight" LineHeight="32" />
                            <TextBlock Text="{Binding Goals}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"
                                       LineStackingStrategy="BlockLineHeight" LineHeight="32" />
                        </StackPanel>
                        <HyperlinkButton x:Name="details" Content="Details anzeigen" Margin="0,6,0,24"
                                         Click="Details_Click" HorizontalAlignment="Left" />
                        
                        <!--Open website-->
                        <Button Click="Website_Click" Style="{StaticResource ListButtonStyle}"
                                Visibility="{Binding Url, Converter={StaticResource StringVisibilityConverter}}">
                            <StackPanel>
                                <TextBlock Text="Website anzeigen" Style="{StaticResource PhoneTextExtraLargeStyle}" />
                            </StackPanel>
                        </Button>                        
                    </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>

            <!--Appointments-->
            <controls:PivotItem Header="Termine">
                <ScrollViewer>
                    <StackPanel>
                        <ListBox ItemsSource="{Binding WeeklyAppointments}" ScrollViewer.VerticalScrollBarVisibility="Disabled">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal" Margin="0,0,0,17" tilt:TiltEffect.IsTiltEnabled="True">
                                        <!--Room-->
                                        <Canvas Height="100" Width="100" Background="{StaticResource PhoneAccentBrush}" Margin="12,0,9,0">
                                            <TextBlock Text="{Binding Location}" Style="{StaticResource PhoneTextNormalStyle}" Foreground="{StaticResource PhoneContrastBrush}" />
                                        </Canvas>
                                        <!--Time/Title-->
                                        <StackPanel>
                                            <TextBlock Text="{Binding TimeSpan}" Style="{StaticResource PhoneTextExtraLargeStyle}" />
                                            <TextBlock Text="{Binding DateSpan}" Margin="12,-6,12,0" Style="{StaticResource PhoneTextAccentStyle}" />
                                            <TextBlock Text="{Binding Subject}" Margin="12,-6,12,0" Style="{StaticResource PhoneTextSubtleStyle}" />
                                        </StackPanel>
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                        <ListBox ItemsSource="{Binding SingleAppointments}" ItemTemplate="{StaticResource AppointmentSingleListTemplate}"
                                 ScrollViewer.VerticalScrollBarVisibility="Disabled" />
                    </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>

            <!--Messages-->
            <controls:PivotItem Header="Nachrichten">
                <ListBox ItemsSource="{Binding Messages}" SelectionChanged="Messages_SelectionChanged">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="0,0,0,16" tilt:TiltEffect.IsTiltEnabled="True">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="9*" />
                                    <ColumnDefinition Width="2*" />
                                </Grid.ColumnDefinitions>

                                <StackPanel Grid.Column="0">
                                    <TextBlock Text="{Binding Sender}" Style="{StaticResource PhoneTextLargeStyle}" />
                                    <TextBlock Text="{Binding Subject}" Style="{StaticResource PhoneTextAccentStyle}" />
                                    <TextBlock Text="{Binding ShortBody}" Style="{StaticResource PhoneTextSubtleStyle}" />
                                </StackPanel>

                                <TextBlock Grid.Column="1" Text="{Binding ReceivedDate}" Style="{StaticResource PhoneTextSmallStyle}"
                                           HorizontalAlignment="Right" Margin="0,16,0,0"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>

        </controls:Pivot>

        <!--Progress Bar-->
        <toolkit:PerformanceProgressBar IsIndeterminate="{Binding IsLoading}" Foreground="{StaticResource PhoneAccentBrush}"
                                        Visibility="{Binding IsLoading, Converter={StaticResource BooleanVisibilityConverter}}"
                                        VerticalAlignment="Top" />


    </Grid>

    <!--ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="Aktualisieren" Click="SyncMessages_Click" />
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>